$(function(){
    let nav = "";
    $.ajax({
        url: "http://chst.vip:1234/api/getindexmenu",
        type: "get",
        data: {}, 
        success(res) {
            let { result } = res;
            result.forEach((item, index, array) => {
                let img=item.img.replace(/images/g,"assets/images");
                nav += `
                <div class="box">
                    <a href="pages/${item.titlehref}">
                        ${img}
                        <p>${item.name}</p>
                    </a>
                </div>
                `
            })
            $('.nav').html(nav);
            $(".box:nth-child(8)").find("a").removeAttr("href");
            $(".box:nth-child(n+9)").slideToggle(0)
            $(".box:nth-child(8)").click(function(){
                $(".box:nth-child(n+9)").slideToggle(200)
            })
        },
        error(err) {
            console.log(err);
        }
    })

    let discount = "";
    $.ajax({
        url: "http://chst.vip:1234/api/getmoneyctrl",
        type: "get",
        data: {}, 
        success(res) {
            let { result } = res;
            result.forEach((item, index, array) => {
                discount += `
                <li>
                    <a href="pages/indexXiang.html?productid=${item.productId}">
                        <div class="left fl">
                            ${item.productImg2}
                        </div>
                        <div class="right">
                            <div class="title">
                                <h4>
                                    ${item.productName}
                                    <span>${item.productPinkage}</span>
                                </h4>
                            </div>
                            <div class="other">
                                <span class="mall">
                                    ${item.productFrom}丨${item.productTime}
                                </span>
                                <span class="fr">
                                    <span class="iconfont">&#xe638;</span>${item.productComCount}
                                </span>
                                
                            </div>
                        </div>
                    </a>
                </li>
                `
            })
            $('.discount>ul').html(discount)
        },
        error(err) {
            console.log(err);
        }
    })
})